﻿using Mb数据插入.Application.DataInsert.Dtos;
using WebFirst.Entities;
using YOUYOU.Models.DTO.HealthFollow;
using YOUYOU.Models.Entities.DBModels;

namespace Mb数据插入.Application
{
    /// <summary>
    /// 系统服务接口
    /// </summary>
    public class TableAppService : IDynamicApiController
    {
        private readonly ITableService _table;
        private readonly ISqlSugarClient _db;
        public TableAppService(ITableService table,ISqlSugarClient db)
        {
            _table = table;
            _db = db;
        }

        /// <summary>
        /// 数据插入
        /// </summary>
        /// <returns></returns>
        public string GetDescription()
        {
            //档案
            List<RecordPatientrecordsg> patient = _db.Queryable<RecordPatientrecords>()
                .LeftJoin<RecordEnrollment>((s,e)=>s.PatientId==e.PatientId).Select((s,e)=>new RecordPatientrecordsg
                {
                    PatientId= s.PatientId,
                    IdCard= s.IdCard,
                    enrollments= e.GroupId==null?"[]":e.GroupId,
                    createDate= s.createDate,
                    Birth=s.Birth,
                    Number= s.Number,
                    Sex=s.Sex.ToString()
                })
                .Where(s=>s.PatientConfirmStatus!=1).ToList();
            //筛查
            List<SiftStrokeup> nczsc = _db.Queryable<SiftStrokeup>().ToList();
            List<SiftCoronary> gxbsc = _db.Queryable<SiftCoronary>().ToList();
            var tnbsc = _db.Queryable<SiftDiabetes>().ToList();
            var gxysc = _db.Queryable<SiftHypertension>().ToList();
            var mxszsc = _db.Queryable<SiftChronicKidneydisease>().ToList();
            var mzfsc = _db.Queryable<SiftCopdup>().ToList();
            //随访
            var mxszsf = _db.Queryable<FollowChronickidneydiseaseup>().ToList();
            var mzfsf = _db.Queryable<FollowCopdup>().ToList();
            var gxbsf = _db.Queryable<FollowCoronaryfollowup>().ToList();
            var tnbsf = _db.Queryable<FollowDiabetesfollowup>().ToList();
            var gxysf = _db.Queryable<FollowHypertensionfollowup>().ToList();
            var nczsf = _db.Queryable<FollowStrokeup>().ToList();
            //公卫表单
            //健康问题评估
            var jkwtpg = _db.Queryable<HealthAssessment>().ToList();
            //心血管风险评估
            var xxgpg = _db.Queryable<CardiovascularAssessment>().ToList();
            //管理方案
            var glfa = _db.Queryable<ManagementScheme>().ToList();
            //生活方式记录
            var shfs = _db.Queryable<ManagementLifestylemanag>().ToList();
            //随访计划
            var plan = _db.Queryable<FollowPlan>().ToList();

             _table.nczsc(patient,nczsc);
            //_table.gxysc(patient, gxysc);
           // _table.tnbsc(patient, tnbsc);
            // _table.gxbsc(patient, gxbsc);
            // _table.mzfsc(patient, mzfsc);
            //_table.mxszsc(patient,mxszsc);
            return "112233";
        }
    }
}
